import java.util.concurrent.BlockingDeque;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

public class prodecerandcustomer {

    public static void main1(String[] args) {
        BlockingQueue<Integer> queue = new LinkedBlockingQueue<>();
        // 然后利用多线程我自己造一个生产者和消费者出来玩
        Thread customer = new Thread(()->{
           while(true){
               try {
                   System.out.println("Customer消费了: "+queue.take());
                   Thread.sleep(600);

               }catch (InterruptedException e){
                   e.printStackTrace();
               }
           }
        });

        Thread producer = new Thread(()->{
            int num = 0;
            while(true){
                try {
                    queue.put(num);
                    System.out.println("Producer生产了: "+ num);
                    num++;
                    Thread.sleep(300);
                }catch (InterruptedException e){
                    e.printStackTrace();
                }
            }
        });
        customer.start();
        producer.start();

    }
}
